#ifndef _GRO_TEXT_H__
#define _GRO_TEXT_H__

#include "GRO_Gui.h"
#include <string>

namespace GRO
{

class ObjectString
{
    private:
    
    public:
    ObjectString()
    {}
    virtual ~ObjectString()
    {}
    
    virtual std::string getString() const
    {
        return "";
    }
};

template<typename T>
class PrimitiveObjectString : public ObjectString
{
    private:
    
    public:
    LinkVar<T> link;
    
    PrimitiveObjectString()
    {}
    PrimitiveObjectString(T* varPtr)
    {
        link.link(varPtr);
    }
    PrimitiveObjectString(const T& var)
    {
        link.set(var);
    }
    virtual ~PrimitiveObjectString()
    {}
    
    virtual std::string getString() const
    {
        return "";
    }
};



class TextBuffer
{
    private:
    
    public:
    std::string text;
    
    std::list<ObjectString*> variables;
    
    
    TextBuffer();
    
    ~TextBuffer();
    
    std::string getString();
    void addVariable(ObjectString* var);
    
};

class Text : public Widget
{
    private:
    std::string text;
    
    public:
    
    TextBuffer buffer;
    
    Text();
    Text(const std::string& text);
    
    virtual ~Text();
    
    virtual void draw(SDL_Rect* clipRect);
    virtual void drawCenter(SDL_Rect* clipRect);
    unsigned int getWidth() const;
    unsigned int getHeight() const;
    
    void refresh();
    
    virtual void connectBeacon(Widget* widget, Beacon* beacon, const std::string& fn_name, const std::vector<std::string>& args);
    
    virtual void updateSize();
    
    virtual std::string get() const;
    virtual void set(const std::string& Text);
    
    virtual TiXmlElement* save(TiXmlElement* parent);
    virtual bool load(TiXmlElement* w);
};







}



#endif
